from utils.convert import *


def combine_product(pro_code: str, pro_list: list):
    """
    组合新商品信息数据
    """
    _temp_dict = pro_list[0]
    _temp_sku_list = []
    _temp_dict["code"] = pro_code
    print(f"处理货号：{pro_code}")
    del _temp_dict["id"]
    for item in pro_list:
        if item["dangerousInfo"]["casNo"] == "":
            del item["dangerousInfo"]
        del item["skuInfos"][0]["differentPrices"]
        del item["skuInfos"][0]["unit"]
        del item["skuInfos"][0]["spuId"]

        _temp_sku_list.append(item["skuInfos"][0])
    _temp_dict["skuInfos"] = _temp_sku_list

    # 设置商品图片
    _temp_dict["photos"] = [
        {
            "photo": "https://bio-mercury-1316961827.cos.ap-guangzhou.myqcloud.com/photos/%E6%BA%90%E5%8F%B6/yuanye_main.png"
        },
        {
            "photo": "https://bio-mercury-1316961827.cos.ap-guangzhou.myqcloud.com/photos/%E6%BA%90%E5%8F%B6/photos%5C2.jpg"
        },
        {
            "photo": "https://bio-mercury-1316961827.cos.ap-guangzhou.myqcloud.com/photos/%E6%BA%90%E5%8F%B6/photos%5C3.jpg"
        },
        {
            "photo": "https://bio-mercury-1316961827.cos.ap-guangzhou.myqcloud.com/photos/%E6%BA%90%E5%8F%B6/photos%5C4.jpg"
        },
        {
            "photo": "https://images.rjmart.cn/image/enqu62up/860d4319-09b2-4af2-8cde-3bb94773fdee.jpg"
        },
    ]

    _temp_dict["desc"] = (
        header_placeholder()
        + add_ad_service()
        + f"""
    <div class="cxsw_yaunye">
        <div>
            商品名：{_temp_dict["name"]}<br>
        </div>
        <img src="https://bio-mercury-1316961827.cos.ap-guangzhou.myqcloud.com/photos/%E6%BA%90%E5%8F%B6/photos1%20%281%29.jpg"
            style="cursor: ns-resize;">
        <br>
        <img src="https://bio-mercury-1316961827.cos.ap-guangzhou.myqcloud.com/photos/%E6%BA%90%E5%8F%B6/photos1%20%282%29.jpg"
            style="cursor: ns-resize;">
        <br>
        <img
            src="https://bio-mercury-1316961827.cos.ap-guangzhou.myqcloud.com/photos/%E6%BA%90%E5%8F%B6/photos1%20%283%29.jpg">
    </div>
    """
        + footer_placeholder()
    )
    return _temp_dict
    # product_list = rj.get_product_list(status=2)
    # print("商品列表获取成功")
    # for product in product_list:
    #     print(product)
    #     break
